package com.orm.base.wrapper;

import com.orm.base.util.ClassUtil;
import com.orm.base.wrapper.base.ECompare;
import com.orm.base.wrapper.base.SFunction;
import com.orm.base.wrapper.base.WhereCondition;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

@Getter
public class MyLambdaQueryWrapper<ENTITY> implements SqlCondition<MyLambdaQueryWrapper<ENTITY>,ENTITY>{


    List<WhereCondition> whereConditions = new ArrayList<>();


    @Override
    public MyLambdaQueryWrapper<ENTITY> eq(boolean condition, SFunction<ENTITY, Object> field, Object value) {
        if (condition) {
            eq(field, value);
        }
        return this;
    }
    @Override
    public MyLambdaQueryWrapper<ENTITY> eq(SFunction<ENTITY, Object> field, Object value) {
        whereConditions.add(new WhereCondition(ClassUtil.convertToFieldName(field), value, ECompare.EQ.getDesc()));
        return this;
    }




}
